package com.zsl.picture.controller;

import com.zjiecode.wxpusher.client.WxPusher;
import com.zjiecode.wxpusher.client.bean.Message;
import com.zsl.picture.util.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zsl
 * @date 2022/1/19
 * @email 154777150@qq.com
 */
@RestController
@RequestMapping("/wxPusher")
public class SendController {
    @Value("${WxPusher.app-token}")
    private String appToken;

    @GetMapping
    public R sendText(@Param("uid") String uid){
        //我的uid
        uid = "UID_MfKLVe6WtjMHMQIFCcqVTXQ90eOm";
        Message message = new Message();
        message.setAppToken(appToken);
        message.setContentType(Message.CONTENT_TYPE_TEXT);
        message.setUid(uid);
        message.setContent("春节快乐");
        message.setUrl("http://zsl.chny.net/notes/user");
        WxPusher.send(message);
        return R.ok("发送成功");
    }
}
